<?php

namespace addons\jieziad;

use app\common\library\Menu;
use think\Addons;

/**
 * 插件
 */
class Jieziad extends Addons
{

    /**
     * 插件安装方法
     * @return bool
     */
    public function install()
    {
        $menu = [
            [
                'name'    => 'jieziad',
                'title'   => '广告管理',
                'icon'    => 'fa fa-map-marker fa-fw',
                'sublist' => [
                    [
                        'name'    => 'jieziad/ad',
                        'title'   => '广告',
                        'icon'    => 'fa fa-circle-o fa-fw',
                        'sublist' => [
                            ['name' => 'jieziad/ad/index', 'title' => '查看'],
                            ['name' => 'jieziad/ad/add', 'title' => '添加'],
                            ['name' => 'jieziad/ad/edit', 'title' => '编辑'],
                            ['name' => 'jieziad/ad/del', 'title' => '删除'],
                            ['name' => 'jieziad/ad/multi', 'title' => '批量更新'],
                        ]
                    ],
                    [
                        'name'    => 'jieziad/ad_position',
                        'title'   => '广告位',
                        'icon'    => 'fa fa-circle-o fa-fw',
                        'sublist' => [
                            ['name' => 'jieziad/ad_position/index', 'title' => '查看'],
                            ['name' => 'jieziad/ad_position/add', 'title' => '添加'],
                            ['name' => 'jieziad/ad_position/edit', 'title' => '编辑'],
                            ['name' => 'jieziad/ad_position/del', 'title' => '删除'],
                            ['name' => 'jieziad/ad_position/multi', 'title' => '批量更新'],
                        ]
                    ],
                    [
                        'name'    => 'jieziad/ad_type',
                        'title'   => '广告类型',
                        'icon'    => 'fa fa-circle-o fa-fw',
                        'sublist' => [
                            ['name' => 'jieziad/ad_type/index', 'title' => '查看'],
                            ['name' => 'jieziad/ad_type/add', 'title' => '添加'],
                            ['name' => 'jieziad/ad_type/edit', 'title' => '编辑'],
                            ['name' => 'jieziad/ad_type/del', 'title' => '删除'],
                        ]
                    ],
                ]
            ]
        ];
        Menu::create($menu);
        return true;
    }

    /**
     * 插件卸载方法
     * @return bool
     */
    public function uninstall()
    {
        Menu::delete("jieziad");
        return true;
    }

    /**
     * 插件启用方法
     * @return bool
     */
    public function enable()
    {
        Menu::enable("jieziad");
        return true;
    }

    /**
     * 插件禁用方法
     * @return bool
     */
    public function disable()
    {
        Menu::disable("jieziad");
        return true;
    }

    /**
     * 实现钩子方法
     * @return mixed
     */
    public function testhook($param)
    {
        // 调用钩子时候的参数信息
        print_r($param);
        // 当前插件的配置信息，配置信息存在当前目录的config.php文件中，见下方
        print_r($this->getConfig());
        // 可以返回模板，模板文件默认读取的为插件目录中的文件。模板名不能为空！
        //return $this->fetch('view/info');
    }
}
